/**
 *  Copyright (c) 2014 The xmlepf project.  All rights reserved.
 *
 *  This file is part of xmlepf (Event Driven Testing Framework).
 *
 *  xmlepf is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  xmlepf is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with xmlepf.  If not, see <http://www.gnu.org/licenses/>.
 *
 *  This software consists of voluntary contributions made by many
 *  individuals.  For exact contribution history, see the revision
 *  history and logs, available at http://code.google.com/p/xmlepf.
 */
package org.xmlepf.xtemp.eventboard;

import java.util.LinkedList;
import java.util.List;
import org.xmlepf.xml.adapter.NodeSerializer;
import org.xmlepf.xml.adapter.XPath;
import org.xmlepf.utils.ObjectCreator;

/**
 *
 *
 */
public class EventBoardInfo {

    private String name = "unknown";
    private String eventStore = "?";
    private String mode = "memory";
    private String scope = "scriptlet";
    private List<EventBoardFilter> boardFilters;

    public EventBoardInfo() {
        boardFilters = new LinkedList<EventBoardFilter>();
    }
    
    public void initialize(String xml) throws Exception {
        XPath xPath = (XPath) ObjectCreator.get("XPath");
        NodeSerializer s = (NodeSerializer) ObjectCreator.get("NodeSerializer");
        xPath.initialize(xml);
        name = s.serialize(xPath.query("/event-board/@name"));
        eventStore = s.serialize(xPath.query("/event-board/@event-store"));
        mode = s.serialize(xPath.query("/event-board/@mode"));

        scope = "script";

        List<String> filtersXml = s.serializeAsList(xPath.query("/event-board/filter"));
        for (String filterXml : filtersXml) {
            EventBoardFilter boardFilter = (EventBoardFilter) ObjectCreator.get("EventBoardFilter");
            boardFilter.initialize(filterXml);
            boardFilters.add(boardFilter);
        }
    }

    public String getName() {
        return name;
    }

    public String getEventStore() {
        return eventStore;
    }

    public String getMode() {
        return mode;
    }

    public String getScope() {
        return scope;
    }

    public void setScope(String scope) {
        this.scope = scope;
    }

    public List<EventBoardFilter> getFilters() {
        return boardFilters;
    }
}
